package com.cpedia.android.deal.activity;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.TabHost;
import com.cpedia.android.deal.R;
import com.google.android.googlelogin.GoogleLoginServiceConstants;
import com.google.android.googlelogin.GoogleLoginServiceHelper;

import java.util.Arrays;

public class HomeActivity extends TabActivity {

    // An arbitrary constant to pass to the GoogleLoginHelperService
    private static final int GET_ACCOUNT_REQUEST = 1;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        final TabHost tabHost = getTabHost();

        tabHost.addTab(tabHost.newTabSpec("tab1")
                .setIndicator(getString(R.string.deal_tab_title))
                .setContent(new Intent(this, CouponList.class)));

        tabHost.addTab(tabHost.newTabSpec("tab2")
                .setIndicator(getString(R.string.coupon_tab_title))
                .setContent(new Intent(this, DealList.class)));

        tabHost.addTab(tabHost.newTabSpec("tab3")
                .setIndicator(getString(R.string.store_tab_title))
                .setContent(new Intent(this, StoreList.class)));
        GoogleLoginServiceHelper.getAccount(this, 123, true);
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == 123) {
            System.out.println(resultCode);
            for (String key : data.getExtras().keySet()) {
                System.out.println(key + ":" +
                        Arrays.toString(data.getExtras().getStringArray(key)));
                String accounts[] = data.getExtras().getStringArray(key);
                //usernameText.setText("You are : " + accounts[0].replace("@gmail.com", ""));
            }
        }
    }
}
